//
//  BaseNavigationController.swift
//  CarShare
//
//  Created by Pro on 2017/12/13.
//

import UIKit

class BaseNavigationController: UINavigationController {

    override func viewDidLoad() {
        super.viewDidLoad()

        navigationBar.barTintColor = APPColor
        // 设置导航栏字体
        navigationBar.barStyle = .black
        //导航栏navigation的translucent属性 影响半透明状态
        UINavigationBar.appearance().isTranslucent = false
        
    }
    
    /// 重写 push 方法，所有的 push 动作都会调用这个方法
    override func pushViewController(_ viewController: UIViewController, animated: Bool) {
        
        if childViewControllers.count > 0 {
            
            viewController.navigationItem.leftBarButtonItem = UIBarButtonItem(title: "", target: self, action: #selector(popToParent), isBack: true)
        }
        
        
        super.pushViewController(viewController, animated: animated)
    }
    /// pop 返回上一级控制器
    @objc private func popToParent() {
        popViewController(animated: true)
    }

}
    
extension UINavigationBar {
        
        open override func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? {

            return super.hitTest(point, with: event)
        }
    
}
